package com.yanqu.road.entity.enums;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public enum eChannelType {

    // VersionTiShen(111, "版号提审渠道", ePlaceType.Other),      //线上没用，用于版号申请

    TaiWan(101, "港澳台正式", ePlaceType.TaiWan),
    TaiWanExperience(900, "港澳台体验", ePlaceType.TaiWan),
    TaiWanTest(901, "港澳台测试", ePlaceType.TaiWan),

    Korea(111, "韩国正式", ePlaceType.Korea),
    KoreaTest(112, "韩国测试", ePlaceType.Korea),
    KoreaExperience(113, "韩国体验", ePlaceType.Korea),
    KoreaInnerTest(703, "内网韩国测试", ePlaceType.Korea),

    Japan(121, "日本正式", ePlaceType.Japan),
    JapanTest(122, "日本测试", ePlaceType.Japan),
    JapanExperience(123, "日本体验", ePlaceType.Japan),
    JapanInnerTest(702, "内网日本测试", ePlaceType.Japan),

    VN(131, "越南正式", ePlaceType.VN),
    VNTest(132, "越南测试", ePlaceType.VN),
    VNExperience(133, "越南体验", ePlaceType.VN),
    VNVersion(134, "越南版号服", ePlaceType.VN),
    VNYunCe(135, "越南云测渠道", ePlaceType.VN),
    VNInnerTest(705, "越南内网测试", ePlaceType.VN),

    Thailand(141, "泰国正式", ePlaceType.Thailand),
    ThailandTest(142, "泰国测试", ePlaceType.Thailand),
    ThailandExperience(143, "泰国体验", ePlaceType.Thailand),
    ThailandInnerTest(704, "泰国内网测试", ePlaceType.Thailand),

    US(151, "美国正式", ePlaceType.US),
    UK(161, "欧洲正式", ePlaceType.UK),

    MainLand(201, "内地正式", true, ePlaceType.MainLand),
    MainLandInnerTest(701, "内网国内测试", true, ePlaceType.MainLand),
    MainLandTest(902, "内地测试", true, ePlaceType.MainLand),
    MainLandBusiness(903, "内地商务包测试", true, ePlaceType.MainLand),

    MainLandFaXingTest(202, "国服发行测试", true, ePlaceType.MainLand),
    MainLandYunCeTest(203, "国服云测", true, ePlaceType.MainLand),
    ChannelTest(211, "渠道考试", true, ePlaceType.MainLand),
    Hun1(221, "华为OV", true, ePlaceType.MainLand),
    Hun2(231, "小米魅族联想金立酷派4399", true, ePlaceType.MainLand),
    Hun3(241, "9U 360 百度 B站", true, ePlaceType.MainLand),
    Tencent(251, "应用宝", true, ePlaceType.MainLand),


    XiaoChengXu(301, "小程序", true, ePlaceType.MainLand),
    XiaoChengXuTest(303, "小程序体验", true, ePlaceType.MainLand),
    ZhiFuBaoTest(333, "支付宝测试", true, ePlaceType.MainLand),
    XiaoChengXuInnerTest(706, "小程序内网测试", true, ePlaceType.MainLand),

    Mobile_QQ(311, "手Q", true, ePlaceType.MainLand),
    Mobile_DY(321, "抖音小游戏", true, ePlaceType.MainLand),
    Mobile_ZFB(331, "支付宝小游戏", true, ePlaceType.MainLand),

    InnerChannel(666, "内网渠道", ePlaceType.TaiWan),

    ;

    // 用Map存，方便取值
    private static final Map<Integer, eChannelType> typeMap = new ConcurrentHashMap<>();

    static {
        for (eChannelType channelType : eChannelType.values()) {
            typeMap.put(channelType.getValue(), channelType);
        }
    }

    private int intValue;

    private String name;

    private boolean useIpLocation;

    private ePlaceType placeType;

    eChannelType(int value, String name, ePlaceType placeType) {
        intValue = value;
        this.name = name;
        useIpLocation = false;
        this.placeType = placeType;
    }

    eChannelType(int value, String name, boolean useIpLocation, ePlaceType placeType) {
        intValue = value;
        this.name = name;
        this.useIpLocation = useIpLocation;
        this.placeType = placeType;
    }

    public int getValue() {
        return intValue;
    }

    public String getName() {
        return name;
    }

    public boolean isUseIpLocation() {
        return useIpLocation;
    }

    public ePlaceType getPlaceType() {
        return placeType;
    }

    public static eChannelType forValue(int value) {
        return typeMap.get(value);
    }

    /**
     * 是否需要先发后审
     * @param channelId
     * @return
     */
    public static boolean needLocalForbidden(int channelId) {
        if (channelId == Korea.getValue() || channelId == KoreaExperience.getValue() || channelId == KoreaTest.getValue()
                || channelId == Japan.getValue() || channelId == JapanTest.getValue() || channelId == JapanExperience.getValue() || channelId == JapanInnerTest.getValue()
                || channelId == VN.getValue() || channelId == VNTest.getValue() || channelId == VNExperience.getValue() || channelId == VNInnerTest.getValue() || channelId == VNVersion.getValue()
                || channelId == Thailand.getValue() || channelId == ThailandExperience.getValue() || channelId == ThailandInnerTest.getValue()
                || channelId == UK.getValue() || channelId == US.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 发言有屏蔽词不发出去
     * @param channelId
     * @return
     */
    public static boolean needHideSelfChat(int channelId) {
        if (channelId == VN.getValue() || channelId == VNTest.getValue() || channelId == VNExperience.getValue() || channelId == VNInnerTest.getValue() || channelId == VNVersion.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否是日本渠道
     * @param channelId
     * @return
     */
    public static boolean isJapanChannel(int channelId) {
        if (channelId == Japan.getValue() || channelId == JapanExperience.getValue() || channelId == JapanInnerTest.getValue() || channelId == JapanTest.getValue()) {
            return true;
        }
        return false;
    }

    /**
     * 是否大陆渠道，包括大陆app、小程序、手Q
     * @param channelId
     * @return
     */
    public static boolean isMainLandChannel(int channelId) {
        for (eChannelType type : eChannelType.values()) {
            if (type.getValue() == channelId) {
                if (type.getPlaceType() == ePlaceType.MainLand)
                    return true;
            }
        }
        return false;
    }

    /**
     * 是否是港澳台渠道
     * @param channelId
     * @return
     */
    public static boolean isTwChannel(int channelId) {
        return channelId == TaiWan.getValue() || channelId == TaiWanExperience.getValue() || channelId == TaiWanTest.getValue();
    }

    public static boolean isNickNameMaxLengthChannel(int channelId) {
        return channelId == VN.getValue()
                || channelId == VNTest.getValue()
                || channelId == VNExperience.getValue()
                || channelId == VNVersion.getValue()
                || channelId == VNInnerTest.getValue()
                || channelId == Thailand.getValue()
                || channelId == ThailandTest.getValue()
                || channelId == ThailandExperience.getValue()
                || channelId == ThailandInnerTest.getValue()
                || channelId == US.getValue()
                || channelId == UK.getValue();
    }

    public static boolean isXiaoChengxuChannel(int channelId) {
        return channelId == XiaoChengXu.intValue
                || channelId == XiaoChengXuTest.intValue
                || channelId == XiaoChengXuInnerTest.intValue
                || channelId == Mobile_QQ.intValue
                || channelId == Mobile_DY.intValue
                || channelId == Mobile_ZFB.intValue
                || channelId == ZhiFuBaoTest.intValue
                ;
    }

    /**
     * 是否大陆渠道，包括大陆app、小程序、手Q
     * @param channelId
     * @return
     */
//    public static boolean isCnChannel(int channelId){
//        return (isMainLandChannel(channelId) || isXiaoChengxuChannel(channelId));
//    }

    /**
     * 是否是韩国渠道
     * @param channelId
     * @return
     */
    public static boolean isKrChannel(int channelId) {
        return channelId == Korea.getValue() || channelId == KoreaTest.getValue() || channelId == KoreaExperience.getValue() || channelId == KoreaInnerTest.getValue();
    }

    /**
    * 描述：是否微信小程序渠道
    * 作者：zrq
    * 时间：2022/1/19
    * 参数：
    渠道编号
    * 返回值：
    **/
    public static boolean isWeixinXiaoChengxuChannel(int channelId) {
        return channelId == XiaoChengXu.intValue || channelId == XiaoChengXuTest.intValue || channelId == XiaoChengXuInnerTest.intValue;
    }

    /**
    * 描述：是否越南渠道
    * 作者：zrq
    * 时间：2022/11/26
    * 参数：

    * 返回值：
    **/
    public static boolean isVnChannel(int channelId) {
        for (eChannelType type : eChannelType.values()) {
            if (type.getValue() == channelId) {
                if (type.getPlaceType() == ePlaceType.VN) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
    * 描述：是否泰国渠道
    * 作者：zrq
    * 时间：2022/11/26
    * 参数：

    * 返回值：
    **/
    public static boolean isThinChannel(int channelId) {
        for (eChannelType type : eChannelType.values()) {
            if (type.getValue() == channelId) {
                if (type.getPlaceType() == ePlaceType.Thailand) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
    * 描述：是否美国渠道
    * 作者：zrq
    * 时间：2022/11/26
    * 参数：

    * 返回值：
    **/
    public static boolean isUsChannel(int channelId) {
        for (eChannelType type : eChannelType.values()) {
            if (type.getValue() == channelId) {
                if (type.getPlaceType() == ePlaceType.US) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
    * 描述：是否英国渠道
    * 作者：zrq
    * 时间：2022/11/26
    * 参数：

    * 返回值：
    **/
    public static boolean isUkChannel(int channelId) {
        for (eChannelType type : eChannelType.values()) {
            if (type.getValue() == channelId) {
                if (type.getPlaceType() == ePlaceType.UK) {
                    return true;
                }
            }
        }
        return false;
    }

    /**
     * 描述：是否抖音渠道
     **/
    public static boolean isDYChannel(int channelId) {
        return channelId == Mobile_DY.getValue();
    }

    /**
     * 是否内网测试渠道
     *
     * @param channelId 渠道Id
     */
    public static boolean isInnerTestChannel(int channelId) {
        return channelId == MainLandInnerTest.intValue
                || channelId == JapanInnerTest.intValue
                || channelId == KoreaInnerTest.intValue
                || channelId == ThailandInnerTest.intValue
                || channelId == VNInnerTest.intValue
                || channelId == XiaoChengXuInnerTest.intValue
                || channelId == InnerChannel.intValue;
    }
}
